import Vue from 'vue'
import App from './App.vue'
import router from './router/index.js'
import {getImgUrl, htmlHanlde} from './service/common'
import {getConfig} from './service/index.js';
import {formatDate} from '@/config/formatDate.js'
Vue.prototype.getImgUrl = getImgUrl;
Vue.prototype.htmlHanlde = htmlHanlde



window.onload = async () => {
  //要执行的js代码段  

  Vue.config.productionTip = false

  Vue.filter('formatDate', function (time) {
    time = time * 1000
    let date = new Date(time)
    return formatDate(date, 'yyyy-MM-dd hh:mm')
  })

 

  let infoList;
  if(!sessionStorage.getItem('system')){
    try{
      let res = await getConfig();
      console.log(res)
      if(res.code == 200){
        infoList = res.data;
        sessionStorage.setItem('system', JSON.stringify(infoList))
      }else{
        throw "错误"
      }
    }catch(e){
      console.log(e)
    }
  }else{
    infoList = sessionStorage.getItem('system');
    infoList = JSON.parse(infoList)
    console.log(infoList)
  }
  Vue.prototype.infoList = infoList;

  new Vue({
    router,
    render: h => h(App),
  }).$mount('#app')

}

import './plugins/vant.js'
import './config/rem.js'